home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / admin / xinetd.2 / xinetd / xinetd.2.1.7-linux.4 / libs / src / timer / ostimer.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-25  |  2.0 KB  |  81 lines

  1. /*
  2.  * (c) Copyright 1993 by Panagiotis Tsirigotis
  3.  * All rights reserved.  The file named COPYRIGHT specifies the terms 
  4.  * and conditions for redistribution.
  5.  */
  6.  
  7. #ifndef OSTIMER_H
  8. #define OSTIMER_H
  9.  
  10. /*
  11.  * Include signal.h to get sigset_t
  12.  */
  13. #ifndef NO_POSIX_SIGS
  14. #include <signal.h>
  15. #endif
  16.  
  17. #include "pq.h"
  18.  
  19. /*
  20.  * Holds a list of timers ordered by expiration time (the one at the
  21.  * head of the list is the one that will expire first).
  22.  */
  23. struct timer_q
  24. {
  25.     pq_h    tq_handle ;
  26.     int    tq_errno ;
  27. } ;
  28.  
  29. /*
  30.  * Macros to handle the priority queue
  31.  */
  32. #define timer_pq_insert( tpq, tp )     pq_insert( tpq, (char *) tp )
  33. #define timer_pq_head( tpq )           (struct timer *) pq_head( tpq )
  34. #define timer_pq_extract_head( tpq )   (struct timer *) pq_extract_head( tpq )
  35. #define timer_pq_delete( tpq, tp )     pq_delete( tpq, (char *) tp )
  36.  
  37.  
  38. typedef enum { AVAILABLE, UNAVAILABLE } availability_e ;
  39.  
  40. /*
  41.  * Description of a timer provided by the operating system
  42.  */
  43. struct os_timer
  44. {
  45.     availability_e        ost_availability ;
  46.     int                    ost_systype ;            /* e.g. ITIMER_REAL                         */
  47.     enum timer_types    ost_timertype ;        /* e.g. TIMER_REAL                        */
  48.     int                    ost_signal ;            /* what signal is generated             */
  49.                                                         /* upon expiration                        */
  50.     void                    (*ost_handler)() ;    /* what function to invoke                */
  51.     void                    (*ost_get_current_time)() ;
  52.                                                     /* how to find the current time            */
  53.     struct timer_q        ost_timerq ;            /* list of timers of this type        */
  54. #ifndef NO_POSIX_SIGS
  55.     sigset_t                ost_block_mask ;        /* signal mask to blocks this timer */
  56. #else
  57.     int                     ost_block_mask ;
  58. #endif
  59. } ;
  60.  
  61. typedef struct os_timer ostimer_s ;
  62.  
  63. #define OSTIMER_NULL                    ((ostimer_s *)0)
  64.  
  65. #define SIGSET_NULL                    ((sigset_t *)0)
  66.  
  67. /*
  68.  * Public functions
  69.  */
  70. ostimer_s    *__ostimer_init() ;
  71. int            __ostimer_newtimer() ;
  72. int            __ostimer_add() ;
  73. void            __ostimer_interrupt() ;
  74. void            __ostimer_remove() ;
  75. void            __ostimer_blockall() ;
  76. void            __ostimer_unblockall() ;
  77. void            __ostimer_unblockall_except() ;
  78.  
  79. #endif    /* OSTIMER_H */
  80.  
  81.